]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
screenshot: Fix stripping suffix from relative filename
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 10 Jan 2020 18:26:05 +0000 (19:26 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Fri, 10 Jan 2020 18:31:04 +0000 (19:31 +0100)
String.prototype.substr() doesn't support a negative length value
(to subtract from the full length), so we end up with a filename
of '' when hitting that code paths (a relative filename with '.png'
suffix).

Fix this by switching to String.prototype.replace() instead.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2091

js/ui/screenshot.js

index 60278a8f3ca3c3404d6e7f31b3b89cec3b553a1d..09f5c5109fb24b2bc9d03866dd86e9b3898f9555 100644 (file)
@@ -65,8 +65,7 @@ var ScreenshotService = class {
     }
 
     *_resolveRelativeFilename(filename) {
-        if (GLib.str_has_suffix(filename, '.png'))
-            filename = filename.substr(0, -4);
+        filename = filename.replace(/\.png$/, '');
 
         let path = [
             GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES),